<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								小组：<input type="text" name="grouptype"/>
							</li>

							<li>
								姓名：<input type="text" name="uname"/>
							</li>
							<li style="clear-after: left">性别：</li>
							<li>
								<select style="width:160px;" id="sex"  type="text">
									<option value=""></option>
									<option value="男">男</option>
									<option value="女">女</option>
									<option value="未知">未知</option>
								</select>
							</li>


							<li>
								民族：<input type="text" name="nations"/>
							</li>

							<li>
								手机：<input type="text" name="phone"/>
							</li>


							<li>学历：</li>
							<li>
								<select style="width:160px;" id="edulevel" name="edulevel"  type="text">
									        <option value=""></option>
											<option value="硕士研究生">硕士研究生</option>
											<option value="本科">本科</option>
											<option value="大专">大专</option>
											<option value="中专">中专</option>
											<option value="高中">高中</option>
											<option value="初中">初中</option>
											<option value="小学">小学</option>
								</select>
							</li>


							<!--<li>-->
								<!--住址：<input type="text" name="address"/>-->
							<!--</li>-->

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="village:partymember:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="village:partymember:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="village:partymember:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-info" onclick="importExcel()">
					<i class="fa fa-upload"></i> 导入
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="village:partymember:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('village:partymember:edit')}]];
        var removeFlag = [[${@permission.hasPermi('village:partymember:remove')}]];
        var prefix = ctx + "village/partymember";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                importTemplateUrl: prefix + "/importTemplate",
                importUrl: prefix + "/importData",
                detailUrl: prefix + "/detail/{id}",
                modalName: "暮云党员",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'pid', 
					title : '数据编号',
					visible: false
				},
				{
					field : 'grouptype', 
					title : '党员小组',
					sortable: true
				},
				{
					field : 'uname', 
					title : '党员姓名',
					sortable: true
				},
				{
					field : 'sex', 
					title : '性别',
					sortable: true
				},
				{
					field : 'nations', 
					title : '民族',
					sortable: true
				},
				{
					field : 'idcard', 
					title : '身份证号码',
					sortable: true
				},
				{
					field : 'edulevel', 
					title : '学历',
					sortable: true
				},
				{
					field : 'partyjoindate', 
					title : '入党时间',
					sortable: true
				},
				{
					field : 'phone', 
					title : '手机号',
					sortable: true
				},
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + '"onclick="$.operate.detail(\'' + row.pid + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
                            return actions.join('');
                        }
                    }]
            };
            $.table.init(options);
        });
    </script>
	 <script>
         // 导入数据
         function importExcel(formId){
             var currentId = $.common.isEmpty(formId) ? 'importTpl' : formId;
             layer.open({
                 type: 1,
                 area: ['400px', '230px'],
                 fix: false,
                 //不固定
                 maxmin: true,
                 shade: 0.3,
                 title: '导入' + $.table._option.modalName + '数据',
                 content: $('#' + currentId).html(),
                 btn: ['<i class="fa fa-check"></i> 导入', '<i class="fa fa-remove"></i> 取消'],
                 // 弹层外区域关闭
                 shadeClose: true,
                 btn1: function(index, layero){
                     var file = layero.find('#file').val();
                     if (file == '' || (!$.common.endWith(file, '.xls') && !$.common.endWith(file, '.xlsx'))){
                         $.modal.msgWarning("请选择后缀为 “xls”或“xlsx”的文件。");
                         return false;
                     }
                     var index = layer.load(2, {shade: false});
                     //$.modal.disable();
                     // 禁用按钮
                     function disable() {
                         var doc = window.top == window.parent ? window.document : window.parent.document;
                         $("a[class*=layui-layer-btn]", doc).addClass("layer-disabled");
                     };
                     var formData = new FormData();
                     formData.append("file", $('#file')[0].files[0]);
                     formData.append("updateSupport", $("input[name='updateSupport']").is(':checked'));
                     $.ajax({
                         url: $.table._option.importUrl,
                         data: formData,
                         cache: false,
                         contentType: false,
                         processData: false,
                         type: 'POST',
                         success: function (result) {
                             if (result.code == web_status.SUCCESS) {
                                 // 关闭全部窗体
                                 layer.closeAll();
                                 // 成功提示
                                 function alertSuccess(content) {
                                     // 弹出提示
                                     layer.alert(content, {
                                         icon: $.modal.icon("success"),
                                         title: "系统提示",
                                         btn: ['确认'],
                                         btnclass: ['btn btn-primary'],
                                     });
                                 }
                                 $.table.refresh();
                             } else if (result.code == web_status.WARNING) {
                                 layer.closeAll();
                                 // 启用按钮
                                 function enable() {
                                     var doc = window.top == window.parent ? window.document : window.parent.document;
                                     $("a[class*=layui-layer-btn]", doc).removeClass("layer-disabled");
                                 }
                                 // 成功提示
                                 function alertSuccess(content) {
                                     // 弹出提示
                                     layer.alert(content, {
                                         icon: $.modal.icon("success"),
                                         title: "系统提示",
                                         btn: ['确认'],
                                         btnclass: ['btn btn-primary'],
                                     });
                                 }
                                 $.modal.alert("warning");
                             } else {
                                 layer.closeAll();
                                 function enable() {
                                     var doc = window.top == window.parent ? window.document : window.parent.document;
                                     $("a[class*=layui-layer-btn]", doc).removeClass("layer-disabled");
                                 }
                                 // 错误提示
                                 function alertError(content) {
                                     // 弹出提示
                                     layer.alert(content, {
                                         icon: $.modal.icon("fail"),
                                         title: "系统提示",
                                         btn: ['确认'],
                                         btnclass: ['btn btn-primary'],
                                     });
                                 }
                                 $.modal.alert("操作失败，插入数据与现有数据重复");
                             }
                         }
                     });
                 }
             });
         }
	 </script>
	 <!-- 导入区域 -->
	 <script id="importTpl" type="text/template">
		 <form enctype="multipart/form-data" class="mt20 mb10">
			 <div class="col-xs-offset-1">
				 <input type="file" id="file" name="file"/>
				 <!--<input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> 是否更新已经存在的用户数据
                  &nbsp;	-->
				 <a onclick="importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 点击下载excel模板</a>
				 <font color="red" class="pull-left mt10">
					 提示：仅允许导入“xls”或“xlsx”格式文件！
				 </font>
			 </div>
		 </form>
	 </script>
	 <script>
         // 下载模板
         function importTemplate() {
             $.get($.table._option.importTemplateUrl, function(result) {XS
                 if (result.code == web_status.SUCCESS) {
                     window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                 } else if (result.code == web_status.WARNING) {
                     $.modal.alertWarning(result.msg)
                 } else {
                     $.modal.alertError(result.msg);
                 }
             });
         }
	 </script>
</body>
</html>